package com.ds.lens.data.common.constant;

import lombok.Getter;

/**
 * Description:
 *
 * @author WeiShaoying
 * @date 2020-03-19
 */
public enum ExternalEventTypeEnum {

    /**
     * 部署开始
     */
    DEPLOYMENT_START(1, "deployment_start", "deployment"),
    /**
     * 部署完成
     */
    DEPLOYMENT_COMPLETED(2, "deployment_completed", "deployment"),
    /**
     * 迁移开始
     */
    MIGRATION_START(3, "migration_start", "migration"),
    /**
     * 迁移完成
     */
    MIGRATION_COMPLETED(4, "migration_completed", "migration"),
    /**
     * 升配开始
     */
    CONFIG_UPGRADE_START(5, "config_upgrade_start", "config_upgrade"),
    /**
     * 升配完成
     */
    CONFIG_UPGRADE_COMPLETED(6, "config_upgrade_completed", "config_upgrade"),
    /**
     * 减配开始
     */
    CONFIG_DOWNGRADE_START(7, "config_downgrade_start", "config_downgrade"),
    /**
     * 减配完成
     */
    CONFIG_DOWNGRADE_COMPLETED(8, "config_downgrade_completed", "config_downgrade"),
    /**
     * 告警
     */
    ALERT(9, "alert", "alert");


    @Getter
    private int code;
    @Getter
    private String name;
    @Getter
    private String eventType;

    ExternalEventTypeEnum(int code, String name, String eventType) {
        this.code = code;
        this.name = name;
        this.eventType = eventType;
    }

    public static ExternalEventTypeEnum valueOf(int code) {
        for (ExternalEventTypeEnum typeEnum : ExternalEventTypeEnum.values()) {
            if (code == typeEnum.getCode()) {
                return typeEnum;
            }
        }
        return null;
    }
}
